package org.atovio.coolexam.common;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;

/**
 * 请求结果类
 */
@lombok.Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Result implements HttpCode {

    private int code;
    private String message;
    private Object data;

    public static Result success() {
        return new Result(SUCCESS, "请求成功", null);
    }

    public static Result success(Object data) {
        return new Result(SUCCESS, "请求成功", data);
    }

    public static Result fail(int code, String msg) {
        return new Result(code, msg, null);
    }

    public static Result serverFail() {
        return new Result(INTERNAL_SERVER_ERROR, "系统错误", null);
    }
}
